<template>
	<view class="purchased">
		<!-- <u-subsection style="margin: 20rpx 0; border-radius: 20rpx;" :list="list" :bold="true" mode="button" bgColor="#fff" activeColor='#000'
			@change="sectionChange" inactiveColor="#999" :current="current"></u-subsection> -->
		<view class="functionalStyle">
			<dynamicList :list="collections"></dynamicList>
		</view>
		<view class="" style="margin-top:  200rpx">
			<u-empty   v-if="collections.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
			</u-empty>
		</view>
		
	</view>
</template>


<script>
	export default {
		data() {
			return {
				list: ['全部', '视频', '图文', '音频'],
				current: 0,
				collections: []
				
			}
		},
		computed: {
			filteredCollections() {
				if (this.current === 0) {
					// 显示全部
					return this.collections;
				} else {
					// 根据activeIndex过滤
					return this.collections.filter(item => item.activeIndex === this.current);
				}
			}
		},
		onLoad() {
			this.$api.theWork().then(res=>{
				console.log("res",res.data)
				this.collections=res.data
			})
		},
		methods: {
			sectionChange(index) {
				this.current = index;
			},
			toggleLove(item) {
				item.is_like = item.is_like === 2 ? 1 : 2;
				item.num_like += item.is_like === 2 ? 1 : -1; // 更新喜欢数量
			},
			gotoOpusDetail(item) {
				console.log("idList", item.id);
				uni.navigateTo({
					url: '/pages/home/opusDetail/opusDetail?id=' + item.id
				});
			},
		}
	}
</script>


<style>
	page {
		background-color: #f6f6f6;
	}

	.purchased {
		width: 100%;
		margin:30rpx auto;
	}

	.flex-container {
		display: flex;
		line-height: 46rpx;
	}

	.collection-item {
		background-color: #fff;
		border-radius: 30rpx;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		margin-bottom: 20rpx;
		padding: 20rpx;
	}

	.collection-item video {
		width: 100%;
		height: 500rpx;
		margin-top: 20rpx;
		border-radius: 13rpx;
	}

	.functionalStyles {
	}

	.icontype {
		display: flex;
		align-items: center;
		width: 95rpx;
	}

	.custom-icon {
		color: red;
		/* 样式颜色 */
	}

	/* 响应式设计 */
	@media (max-width: 768px) {
		.category-list li {
			flex: 1 0 48%;
			/* 在小屏幕上，每行显示两个分类 */
		}
	}
	.functionalStyle {
	}
	.avatar {
		width: 90rpx;
		height: 90rpx;
		border-radius: 50%;
		margin-right: 30rpx;
	}

	.info {
		display: flex;
		flex-direction: column;
	}

	.name {
		color: #000;
		font-weight: 550;
		font-size: 30rpx;
		margin-right: 10rpx;
	}

	.age,
	.time-ago {
		font-size: 24rpx;
		color: #6d6d6d;
	}

	.content {
		margin: 20rpx 0;
		font-weight: 550;
	}
</style>